package com.hspedu.newData.dmsxl.数组;

import org.junit.Test;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-10 
 * @Version: 1.0
 */

public class LC575分糖果 {

    public int distributeCandies(int[] candyType) {

        Set<Integer> set = new HashSet<>();

        int len1 = candyType.length;
        for (int i = 0; i < len1; i++) {
            set.add(candyType[i]);
        }

        int len = set.size();

        int res = len > len1/2 ? len1/2 : len;
        return res;

    }

    @Test
    public void test() {
        // 测试代码

        distributeCandies(new int[]{6,6,6,6});
    }

}
